<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$sid=$this->checklogin();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid'],'sid'=>$sid);
   
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_supplier_log',$params,array($pindex,$psize),$total,'','',$orderby);
	foreach($return['list'] as &$v){
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
		$v['paytime']=date('Y-m-d H:i:s',$v['paytime']);
		
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'提现日志'),
			array('op'=>'edit','title'=>'申请提现'),
		),
		'list'=>array('data'=>'list','del_one'=>false,'delall'=>false,'edit'=>false,'list'=>array(
			array('name'=>'money','title'=>'金额','type'=>'string'),
			array('name'=>'createtime','title'=>'提现时间','type'=>'string'),
			array('name'=>'account','title'=>'账号','type'=>'string'),
			array('name'=>'name','title'=>'收款人','type'=>'string'),
			array('name'=>'type','title'=>'账号类型','type'=>'radio','options'=>'type'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'remark','title'=>'备注','type'=>'string'),
			array('name'=>'paytime','title'=>'打款时间','type'=>'string'),
		)),
	);
	$return['type']=array('1'=>'支付宝','2'=>'银行卡');
	$return['status']=array('0'=>'申请中','1'=>'已打款','2'=>'已拒绝');
	$return['htmls']=$htmls;
	exi($return);
	}
if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	
    $can=pdo_getcolumn('jy_supplier_user',array('mid'=>$sid),'money');
	$return['item']['can']=$can?$can:0.00;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'提现申请',
		'tabs'=>array(
			array('op'=>'list','title'=>'提现日志'),
			array('op'=>'edit','title'=>'申请提现')
		),
		'edit'=>array(
			array('name'=>'can','title'=>'可提现金额','type'=>'string','read'=>true),
			array('name'=>'money','title'=>'提现金额','type'=>'string'),
			array('name'=>'name','title'=>'收款人','type'=>'string'),
			array('name'=>'type','title'=>'账号类型','type'=>'radio','options'=>'type'),
			array('name'=>'account','title'=>'账号','type'=>'string'),
			)
			);
	$return['type']=array('1'=>'支付宝','2'=>'银行卡');
	$return['htmls']=$htmls;
	exi($return);
	}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	$can=pdo_getcolumn('jy_supplier_user',array('mid'=>$sid),'money');
	$data=array_fields(array('name','type','account','money'),$postdata);
	if($can<$data['money']){
		exi('超过可提现金额','');
	}
	$data['uniacid']=$_SESSION['uniacid'];
	$data['createtime']=time();
	$data['sid']=$sid;
	pdo_update('jy_supplier_user',array('money -='=>$data['money']),array('mid'=>$sid));
	pdo_insert('jy_supplier_log',$data);
	exi('申请成功！','','list');
}

?>